﻿using DayuCode.Designer.Entity;
using DayuCode.Designer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DayuCode.Designer.Service
{
    public class ProjectHandler
	{
		private static string getBaseUrl(string methodName)
		{
			return AppInstance.ApiServer + "api/base/dayucode_projectHandler/" + methodName;
		}
		public static IList<ZTreeNode> getProjectTreeNodes(string pId)
		{
			IList<ZTreeNode> obj = QHttpClient.Post<List<ZTreeNode>>(getBaseUrl("getProjectTreeNodes"), new { pId = pId });
			return obj;
		}

		public static IList<Project> getAllProjects()
		{
			IList<Project> obj = QHttpClient.Post<List<Project>>(getBaseUrl("getAllProjects"), new { });
			return obj;
		}
		public static IList<Project> getProjects(long catalogId)
		{
			IList<Project> obj = QHttpClient.Post<List<Project>>(getBaseUrl("getProjects"), new { catalogId = catalogId });
			return obj;
		}

		public static void deleteProject(long id)
		{
			QHttpClient.Execute(getBaseUrl("deleteProject"), new { id = id });
		}

		public static Project saveProject(Project item)
		{
			Project obj = QHttpClient.Post<Project>(getBaseUrl("saveProject"), new { item = item });
			return obj;
		}

		public static Project getProject(long id)
		{
			Project obj = QHttpClient.Post<Project>(getBaseUrl("getProject"), new { id = id });
			return obj;
		}

		public static ProjectVO getProjectVO(long id)
		{
			ProjectVO obj = QHttpClient.Post<ProjectVO>(getBaseUrl("getProjectVO"), new { id = id });
			return obj;
		}

		public static UploadFileInfo uploadPdmFile(string filePath)
		{
			UploadFileInfo fileInfo = QHttpClient.UploadFile<UploadFileInfo>(getBaseUrl("uploadPdmFile"), filePath);
			return fileInfo;
		}
	}
}
